from userinfo import *
dict1 = {'name':'乔安生','age':18}


#遍历字典
def func1():
	for x in dict1:
	    print(x,dict1[x])
		#输出：
		#name 乔安生
		#age 18


#遍历字典的Key
def func2():
	for x in dict1.keys():
	    print(x);
		#输出：
		#name
		#age

#遍历字典的Value
def func3():
	for x in dict1.values():
	    print(x);
		#输出：
		#乔安生
		#18

#遍历字典项
def func4():
	for x in dict1.items():
	    print(x);
		#输出：
		#('name', '乔安生')
		#('age', 18)

func1()
func2()
func3()
func4()

user1 = UserInfo('张三',18)
user2 = UserInfo('李四',19)
user3 = UserInfo('王二',31)
user4 = UserInfo('麻子',55)
user5 = UserInfo('赵六',72)
dict2 = {"userId:1":user1,"userId:2":user2,"userId:3":user3,"userId:4":user4}
def func5():
	for x in dict2:
	    print(x)
		#输出：
		#userId:1
		#userId:2
		#userId:3
		#userId:4

def func6():
	for x in dict2.items:#运行时错误
	    print(x)


def func7():
	for x in dict2.values():
	    print(x)
		#输出：
		#<userinfo.UserInfo object at 0x0000012DBF95BA20>
		#<userinfo.UserInfo object at 0x0000012DBF95BA58>
		#<userinfo.UserInfo object at 0x0000012DBF95B9E8>
		#<userinfo.UserInfo object at 0x0000012DBF95BBE0>
def func8():
	for x in dict2.values():
	    print(x.name,x.age)
		#输出：
		#张三 18
		#李四 19
		#王二 31
		#麻子 55

func5()
#func6() #运行时错误
func7()
func8()

